package com.tim.third.demo.printer.ysy;


import org.apache.http.client.ClientProtocolException;

import java.io.IOException;


public class PrinterUtilTest {
    
	
	public void print() throws ClientProtocolException, IOException {
		String url = "https://open-api.ushengyun.com/printer/print";
	    
		String reqBody = PrinterUtil.getReqBody("printdata", "<W2>exec</W2>");

		//请求数据
		PrinterUtil.sendPost(url, reqBody);
	}

	
	public void sound() throws ClientProtocolException, IOException {
		String url = "https://open-api.ushengyun.com/printer/sound";
	    
		String reqBody = PrinterUtil.getReqBody("sound", "1");

		//请求数据
		PrinterUtil.sendPost(url, reqBody);
	}

	
	public void status() throws ClientProtocolException, IOException {
		String url = "https://open-api.ushengyun.com/printer/status";
	    
		String reqBody = PrinterUtil.getReqBody("", "");

		//请求数据
		PrinterUtil.sendPost(url, reqBody);
	}

	
	public void emptyprintqueue() throws ClientProtocolException, IOException {
		String url = "https://open-api.ushengyun.com/printer/emptyprintqueue";
	    
		String reqBody = PrinterUtil.getReqBody("", "");

		//请求数据
		PrinterUtil.sendPost(url, reqBody);
	}

	
	public void cancelone() throws ClientProtocolException, IOException {
		String url = "https://open-api.ushengyun.com/printer/cancelone";
	    
		String reqBody = PrinterUtil.getReqBody("dataid", "41834171");
//		JSONObject jsonObject = JSON.parseObject(reqBody);
//		jsonObject.remove("deviceid");
//		jsonObject.remove("devicesecret");
//		reqBody = JSONUtil.formatJsonStr(JSON.toJSONString(jsonObject));
//		System.out.println(reqBody);

		//请求数据
		PrinterUtil.sendPost(url, reqBody);
	}

}
